package com.sharyuke.app.ui

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.chad.library.adapter.base.entity.SectionEntity
import com.sharyuke.app.R
import com.sharyuke.utils.adapterSection
import com.sharyuke.utils.withRecyclerView

class ViewListGroupActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_view_list_group)
        val list = listOf(
            ItemGroup("first", true),
            ItemGroup("second", false),
            ItemGroup("second", false),
            ItemGroup("second", false),
            ItemGroup("first", true),
            ItemGroup("second", false),
            ItemGroup("second", false),
            ItemGroup("first", true),
        )
        val se = list.plus(list).plus(list)
        adapterSection(R.layout.item_group_header, R.layout.item_group_item, se.plus(se).plus(se)) {
            onHasTitle { setText(R.id.header_name, name) }
            onHasItem { setText(R.id.item_name, name) }
        }.withRecyclerView(findViewById(R.id.view_list_group_rv))
    }
}

data class ItemGroup(val name: String, val header: Boolean) : SectionEntity {
    override val isHeader: Boolean = header
}